#ifndef _FNT_COMPUTE_THREAD_H_
#define _FNT_COMPUTE_THREAD_H_

#include <QThread>

class Tracer;
class Session;
struct Path;
struct Position;
class Graph;
struct Cube;
class Algorithm;
class OptionsPage;
class Options;

struct ComputeThreadPriv;
class ComputeThread: public QThread {
	Q_OBJECT;
	friend struct ComputeThreadPriv;
	ComputeThreadPriv*const priv;
	void run() override;

Q_SIGNALS:
	void threadWarning(const QString& info);
	void threadError(const QString& info);
	void computeFinished();
	void showProgress();

	public:
	ComputeThread(Session* s);
	~ComputeThread();

	void stop();

	void find(const Position& p0, Graph gr);
	void connect(const Position& p0, const Position& p1, Graph gr);
	void refine(const Path& pth, Graph gr);

	void cancel();

	void updateCube(int ch, const Cube& cube, const std::pair<double, double>& xfunc);
	void updateXfunc(int ch, const std::pair<double, double>& xfunc);
	void positionChanged();

	bool sync(Algorithm* alg);
	const std::vector<int32_t>& progressData() const;
	void progressDataUpdated();

	bool getPath(Path* path, bool* connected);

	void saveOptions(Options* opt) const;

	void attachOptionsDlg();
	void detachOptionsDlg();
};

#endif
